﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HRM.BusinessLogic
{
    public class PositionDetail_Info : Standard_Info
    {
        public PositionDetail_Info()
        {
        }

        private int _PD_ID;

        public int PD_ID
        {
            get { return _PD_ID; }
            set { _PD_ID = value; }
        }
        private int _PD_EmployeeID;

        public int PD_EmployeeID
        {
            get { return _PD_EmployeeID; }
            set { _PD_EmployeeID = value; }
        }
        private DateTime _PD_BeginDate;

        public DateTime PD_BeginDate
        {
            get { return _PD_BeginDate; }
            set { _PD_BeginDate = value; }
        }
        private DateTime _PD_EndDate;

        public DateTime PD_EndDate
        {
            get { return _PD_EndDate; }
            set { _PD_EndDate = value; }
        }
        private int _PD_PositionID;

        public int PD_PositionID
        {
            get { return _PD_PositionID; }
            set { _PD_PositionID = value; }
        }
        private int _PD_DepartmentID;

        public int PD_DepartmentID
        {
            get { return _PD_DepartmentID; }
            set { _PD_DepartmentID = value; }
        }

        private int _PD_GradeID;

        public int PD_GradeID
        {
            get { return _PD_GradeID; }
            set { _PD_GradeID = value; }
        }

        private bool _PD_IsActive;

        public bool PD_IsActive
        {
            get { return _PD_IsActive; }
            set { _PD_IsActive = value; }
        }

        private string _PD_Description;

        public string PD_Description
        {
            get { return _PD_Description; }
            set { _PD_Description = value; }
        }

        private int _PD_LevelID;

        public int PD_LevelID
        {
            get { return _PD_LevelID; }
            set { _PD_LevelID = value; }
        }

        private decimal _PD_MinSalary;

        public decimal PD_MinSalary
        {
            get { return _PD_MinSalary; }
            set { _PD_MinSalary = value; }
        }

        //
        private decimal _PD_BasicFactor;

        public decimal PD_BasicFactor
        {
            get { return _PD_BasicFactor; }
            set { _PD_BasicFactor = value; }
        }

        private decimal _PD_BasicSalary;

        public decimal PD_BasicSalary
        {
            get { return _PD_BasicSalary; }
            set { _PD_BasicSalary = value; }
        }

        private decimal _PD_PositionFactor;

        public decimal PD_PositionFactor
        {
            get { return _PD_PositionFactor; }
            set { _PD_PositionFactor = value; }
        }

        private decimal _PD_PositionAllowance;

        public decimal PD_PositionAllowance
        {
            get { return _PD_PositionAllowance; }
            set { _PD_PositionAllowance = value; }
        }

        private int _PD_OverFactorPercent;

        public int PD_OverFactorPercent
        {
            get { return _PD_OverFactorPercent; }
            set { _PD_OverFactorPercent = value; }
        }

        private decimal _PD_OverFactor;

        public decimal PD_OverFactor
        {
            get { return _PD_OverFactor; }
            set { _PD_OverFactor = value; }
        }

        private decimal _PD_OverAllowance;

        public decimal PD_OverAllowance
        {
            get { return _PD_OverAllowance; }
            set { _PD_OverAllowance = value; }
        }

        private int _PD_JobFactorPercent;

        public int PD_JobFactorPercent
        {
            get { return _PD_JobFactorPercent; }
            set { _PD_JobFactorPercent = value; }
        }

        private decimal _PD_JobFactor;

        public decimal PD_JobFactor
        {
            get { return _PD_JobFactor; }
            set { _PD_JobFactor = value; }
        }


        private decimal _PD_JobAllowance;

        public decimal PD_JobAllowance
        {
            get { return _PD_JobAllowance; }
            set { _PD_JobAllowance = value; }
        }

        private decimal _PD_AreaFactor;

        public decimal PD_AreaFactor
        {
            get { return _PD_AreaFactor; }
            set { _PD_AreaFactor = value; }
        }

        private decimal _PD_AreaAllowance;

        public decimal PD_AreaAllowance
        {
            get { return _PD_AreaAllowance; }
            set { _PD_AreaAllowance = value; }
        }

        private decimal _PD_TelephoneAllowance;

        public decimal PD_TelephoneAllowance
        {
            get { return _PD_TelephoneAllowance; }
            set { _PD_TelephoneAllowance = value; }
        }

        private decimal _PD_LunchAllowance;

        public decimal PD_LunchAllowance
        {
            get { return _PD_LunchAllowance; }
            set { _PD_LunchAllowance = value; }
        }


        private decimal _PD_OtherAllowance;

        public decimal PD_OtherAllowance
        {
            get { return _PD_OtherAllowance; }
            set { _PD_OtherAllowance = value; }
        }

        //
        private decimal _PD_TotalSalary;

        public decimal PD_TotalSalary
        {
            get { return _PD_TotalSalary; }
            set { _PD_TotalSalary = value; }
        }

        private string _PD_Job;

        public string PD_Job
        {
            get { return _PD_Job; }
            set { _PD_Job = value; }
        }


        private decimal _PD_OtherFactor;

        public decimal PD_OtherFactor
        {
            get { return _PD_OtherFactor; }
            set { _PD_OtherFactor = value; }
        }



        private bool _PD_LaterInsurance;

        public bool PD_LaterInsurance
        {
            get { return _PD_LaterInsurance; }
            set { _PD_LaterInsurance = value; }
        }

        private DateTime _PD_DatePositionEnd;

        public DateTime PD_DatePositionEnd
        {
            get { return _PD_DatePositionEnd; }
            set { _PD_DatePositionEnd = value; }
        }

        private DateTime _PD_DatePositionBegin;

        public DateTime PD_DatePositionBegin
        {
            get { return _PD_DatePositionBegin; }
            set { _PD_DatePositionBegin = value; }
        }
        private DateTime _PD_DateSalary;

        public DateTime PD_DateSalary
        {
            get { return _PD_DateSalary; }
            set { _PD_DateSalary = value; }
        }
        private string _PD_Type;

        public string PD_Type
        {
            get { return _PD_Type; }
            set { _PD_Type = value; }
        }
        private DateTime _PD_DatePC;

        public DateTime PD_DatePC
        {
            get { return _PD_DatePC; }
            set { _PD_DatePC = value; }
        }
        private DateTime _PD_DateTNVK;

        public DateTime PD_DateTNVK
        {
            get { return _PD_DateTNVK; }
            set { _PD_DateTNVK = value; }
        }
        private DateTime _PD_DateTNN;

        public DateTime PD_DateTNN
        {
            get { return _PD_DateTNN; }
            set { _PD_DateTNN = value; }
        }
    }
    
    public class PositionDetail_Controller : Standard_Controller
    {
        #region "Contructor"
        private static PositionDetail_Controller _instance;
        protected PositionDetail_Controller() { }
        protected void Dispose()
        {
            _instance = null;
        }
        private static object _syncLock = new object();
        public static PositionDetail_Controller Instance()
        {
            if (_instance == null)
            {
                lock (_syncLock)
                {
                    if (_instance == null)
                        _instance = new PositionDetail_Controller();
                }
            }
            return _instance;
        }
        public static PositionDetail_Controller Instance(String transName)
        {
            if (!String.IsNullOrEmpty(transName))
            {
                PositionDetail_Controller _instanceTrans = new PositionDetail_Controller();
                _instanceTrans.Trans_Name = transName;
                return _instanceTrans;
            }
            else
                return Instance();
        }
        #endregion
        public const String cs_Table_Name = "";

        public PositionDetail_Info PositionDetail_GetInfo(int Employee_ID)
        {
            return CBO.FillObject<PositionDetail_Info>(DataConnect.ExecuteRow(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_PositionDetail_GetInfoByEmployee", false), Employee_ID));
        }

        public int PositionDetail_InsertNS(PositionDetail_Info eInfo)
        {
            return Globals.Object_GetValue<int>(DataConnect.ExecuteScalar(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_PositionDetail_InsertNS"),
                eInfo.PD_EmployeeID,
                eInfo.PD_PositionID,
                eInfo.PD_DepartmentID,
                eInfo.PD_BeginDate,
                Globals.DB_GetNull(eInfo.PD_BasicFactor,0),
                Globals.DB_GetNull(eInfo.PD_BasicSalary,0),
                Globals.DB_GetNull(eInfo.PD_OtherAllowance,0),
                Globals.DB_GetNull(eInfo.PD_PositionFactor,0),
                Globals.DB_GetNull(eInfo.PD_PositionAllowance,0),
                Globals.DB_GetNull(eInfo.PD_OverFactorPercent, 0),
                Globals.DB_GetNull(eInfo.PD_OverFactor,0),
                Globals.DB_GetNull(eInfo.PD_OverAllowance,0),
                Globals.DB_GetNull(eInfo.PD_JobFactorPercent, 0),
                Globals.DB_GetNull(eInfo.PD_JobFactor,0),
                Globals.DB_GetNull(eInfo.PD_JobAllowance, 0),
                eInfo.PD_DateSalary,
                eInfo.PD_DatePC,
                eInfo.PD_DateTNVK,
                eInfo.PD_DateTNN
                ));
        }

        public bool PositionDetail_UpdateNS(PositionDetail_Info eInfo)
        {
            return Globals.Object_GetValue<bool>(DataConnect.ExecuteNonQuery(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_PositionDetail_UpdateNS"),
                eInfo.PD_ID,
                eInfo.PD_EmployeeID,
                eInfo.PD_PositionID > 0 ? eInfo.PD_PositionID : (int ?)null,
                eInfo.PD_DepartmentID > 0 ? eInfo.PD_DepartmentID : (int ?) null,
                eInfo.PD_BeginDate,
                Globals.DB_GetNull(eInfo.PD_BasicFactor, 0),
                Globals.DB_GetNull(eInfo.PD_BasicSalary, 0),
                Globals.DB_GetNull(eInfo.PD_OtherAllowance, 0),
                Globals.DB_GetNull(eInfo.PD_PositionFactor, 0),
                Globals.DB_GetNull(eInfo.PD_PositionAllowance, 0),
                Globals.DB_GetNull(eInfo.PD_OverFactorPercent, 0),
                Globals.DB_GetNull(eInfo.PD_OverFactor, 0),
                Globals.DB_GetNull(eInfo.PD_OverAllowance, 0),
                Globals.DB_GetNull(eInfo.PD_JobFactorPercent, 0),
                Globals.DB_GetNull(eInfo.PD_JobFactor, 0),
                Globals.DB_GetNull(eInfo.PD_JobAllowance, 0),
                eInfo.PD_DateSalary,
                eInfo.PD_DatePC,
                eInfo.PD_DateTNVK,
                eInfo.PD_DateTNN) > 0);
        }
    }
}
